﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using Entity;
using Command;

namespace DAL
{
    public class X_Shopcart
    {
        //获取购物车的所有数据
        public static List<ShoppingCart> Get( int uid)
        {

            string sql = "select * from ShoppingCart";
            List<ShoppingCart> list = new List<ShoppingCart>();
            SqlDataReader dr = DBHelper.Getdata(sql);
            while (dr.Read())
            {
                ShoppingCart s = new ShoppingCart();
                s.CartId = (int)dr["CartId"];
                s.UserID = (int)dr["UserID"];
                s.BookId = (int)dr["BookId"];
                s.CartCount = (int)dr["CartCount"];
                list.Add(s);
            }
            dr.Close();
            return list;
        }
       //添加购物车
        public static int Insertcart(ShoppingCart sc)
        {
            string sql = string.Format("insert into ShoppingCart ([UserID],[BookId],[CartCount]) values ('{0}','{1}','{2}')",sc.UserID,sc.BookId,sc.CartCount);
            return DBHelper.Adddata(sql);
        }
        //修改购物车
        public static int Updatashop(ShoppingCart sc)
        {
            string sql = "";
            return DBHelper.Adddata(sql);
        }
        //删除
        public static int Delshop(ShoppingCart sc)
        {
            string sql = "";
            return DBHelper.Adddata(sql);
        }
    }
}
